package com.github.thinwonton.springboot.showcase.rmq;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MessageController {
    @Autowired
    private AmqpTemplate amqpTemplate;

    @RequestMapping("/send")
    @ResponseBody
    public String send() {
        amqpTemplate.convertAndSend(RMQConfig.QUEUE_NAME,
                "message:" + System.currentTimeMillis());
        return "ok";
    }
}
